package com.cn.Sevelt;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cn.dao.Userdao;
@WebServlet(name="xiangting",urlPatterns="/yangqin")
public class Usersevlet extends HttpServlet {
	public void destroy() {
		super.destroy(); 
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Userdao dao=new Userdao();
		String pass=request.getParameter("password");
		String name=request.getParameter("user");
		if(dao.Banduan(name, pass))
		{
			request.getRequestDispatcher("index.jsp").forward(request, response);
		}
		else
		{
			request.setAttribute("shibai","登陆失败");
			request.getRequestDispatcher("DengLu.jsp").forward(request, response);
		}

	}

	public void init() throws ServletException {
	}

}
